Hệ thống quản lý trường học bằng PHP / MySQLi
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title>Password Reminder</title>
6 <meta charset="utf-8">
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <title>school management system</title>
9 <link rel="shortcut icon" href="assets/img/title.gif" type="image/x-icon">
10 <link rel="stylesheet" href="assets/css/bootstrap.min.css">
11 <link href="assets/css/loader.css" rel="stylesheet" />
12 <script src="assets/js/canvasjs.min.js"></script>
13 <!--*****jquery -3.2.1.js file supports the use of dropdown***-->
14 <script src="assets/js/jquery-3.2.1.js"></script>
15
16 </head>
17 <body>
18
19 <div class="col-md-12" style="background-color:#526F35; position:relative;top:0px;">
20 <p class="text-center text-danger" style="color:white;" > Enter your email in the form below to have your password sent to you.</p>
21 </div>
22
23 <?php
24 if (!array_key_exists('Submitted',$_POST))
25 {
26 ?>
27 <div class="row">
28 <div class="col-sm-3">
29 </div>
30 <div class="col-sm-6" >
31
32 <br>
33 <br>
34 <br>
35
36 <div >
37 <form method="post" action="email.php">
38 <input type="hidden" name="Submitted" value="true"><br>
39 <label>Email: </label>
40 <input type="text" name="To" size="25" class="form-control"><br>
41 <input type="submit" value="Send Password">
42 </form>
43 </div>
44 <?php
45 }
46 else
47 {
48 $to = $_POST['To'];
49 @$db = new mysqli('localhost','root','','sms2');
50 if (mysqli_connect_errno())
51 {
52 echo 'Cannot connect to database: ' . mysqli_connect_error();
53 }
54 else
55 {
56 $query = "SELECT password, fname FROM admin WHERE email = '$to'";
57 $result = $db->query($query);
58 $row=$result->fetch_assoc();
59 $password = $row['password'];
60 $fname = $row['fname'];
61 //Sending of password using phpmmailer
62 require("PHPMailer_5.2.0/class.phpmailer.php");
63
64 $message = "Hello $fname.<br> Your password is <u>$password</u>.";
65
66 $mail = new PHPMailer(); //Use phpmailer to send instead of inbult php mail()
67 $mail->isSMTP(); // Set mailer to use SMTP
68 $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
69 $mail->SMTPAuth = true; // Enable SMTP authentication
70 $mail->Username = 'emaxsystemmailer@gmail.com';// SMTP username
71 $mail->Password = 'john100john'; // SMTP password
72 $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
73 $mail->FromName = "Mailer";
74 $mail->WordWrap = 50; // set word wrap
75 $mail->IsHTML(true); // send as HTML
76 $mail->Port = 465; // TCP port to connect to
77
78 $mail->From = 'emaxsystemmailer@gmail.com';
79 $mail->FromName = 'System Admin';
80 $mail->AddAddress($to); //change it to your email address to actually get the email!
81 $mail->AddBCC('jmuthama78@yahoo.com');
82 $mail->AddReplyTo('emaxsystemmailer@gmail.com');
83
84 $mail->Subject = 'password Reminder';
85 $mail->Body = $message;
86
87 if($mail->Send())
88 {
89 echo "Your password has been sent.";
90 echo '<br>';
91 echo '<a button class="btn btn-success" title="Click to bo back"
92 href="index.php">Back</a>';
93 }
94 else
95 {
96 echo "We could not send your password.<br>";
97 echo "Mailer Error: " . $mail->ErrorInfo;
98 echo '<br>';
99 echo '<a button class="btn btn-success" title="Click to bo back"
100 href="index.php">Back</a>';
101 }
102 }
103 }
104 ?>
105
106 </div>
107
108 <div class="col-md-12" style="background-color:#526F35; position:fixed;bottom:0px;">
109 <p class="text-center text-danger" style="color:white;" >@J. Muthama Tel: +254729734768</p>
110 </div>
111 </body>
112 </html>